﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LibraryMangementSystem.CertManage
{
    public partial class CertLogout : Form
    {
        public CertLogout()
        {
            InitializeComponent();
        }
        LibraryEntities1 dbContext = new LibraryEntities1();
        private void button1_Click(object sender, EventArgs e)
        {
            var Cert_Id = textBoxCertId.Text;
            if(Cert_Id != "")
            {
                CertificateInfo cert = dbContext.CertificateInfo.Single(C => C.Cert_id == Cert_Id);
                dbContext.Entry<CertificateInfo>(cert).State = System.Data.Entity.EntityState.Deleted;
                int res = dbContext.SaveChanges();
                String str = res == 1 ? "注销成功！" : "注销失败!";
                MessageBox.Show(str);
            }
            else
            {
                MessageBox.Show("请输入借书证号！");
            }
            
        }
    }
}
